import {reactive,ref} from 'vue'
import Axios from 'axios'
import { ElMessage } from 'element-plus'

export default function(){
    const dogs = reactive([])
    async function getDogs(){
        try{
            const result = await Axios.get('https://dog.ceo/api/breed/collie/border/images/random') 
            dogs.push(result.data.message)
        }catch(error){
            ElMessage({
                message:'小狗照片未能得到，请尝试重新获取',
                type:'error'
            })
        }
    }
    return{dogs,getDogs}
}